<?php
/**
 * 关键词分析
 *
 *
 ***/

defined('InShopNC') or exit('Access Invalid!');
class keyControl extends SystemControl{
    const EXPORT_SIZE = 5000;
    public function __construct() {
        parent::__construct ();
        //Language::read('goods');
    }
    
    
    public function key_hotOp(){
        $period=$_GET['period'];
        if (empty($period)){
            $period='current';
        }
        $condition=array();
        $todays=date("Y-m-d").' 00:00:00';
        $todaye=date("Y-m-d").' 23:59:59';
        $todays=strtotime($todays);
        $todaye=strtotime($todaye);
        
        switch ($period) {
            case 'current':
                $condition['start']=$todays;
                $condition['end']=TIMESTAMP;
            break;
            case 'yesterday':
                $condition['start']=$todays-86400;
                $condition['end']=$todays-1;
            break;
            case 'week':
                $condition['start']=$todaye-604800;
                $condition['end']=TIMESTAMP;
            break;
            case 'mouth':
                $condition['start']=$todaye-2592000;
                $condition['end']=TIMESTAMP;
            break;
            
            default:
                $condition['start']=$todays;
                $condition['end']=TIMESTAMP;
            break;
        }
        $model_key=Model('key');
        $key_list=$model_key->getKeyList($condition);
        
        Tpl::output('period',$period);
        Tpl::output('key_list',$key_list);
        Tpl::showpage('key.key_list');
    }
    
    /**
     * 根据关键词查找详情
     */
    public function key_detailOp(){
        $period=$_GET['period'];
        $condition=array();
        $todays=date("Y-m-d").' 00:00:00';
        $todaye=date("Y-m-d").' 23:59:59';
        $todays=strtotime($todays);
        $todaye=strtotime($todaye);
        switch ($period) {
            case 'current':
                $condition['key_time']=array(array('egt', $todays),array('lt',TIMESTAMP),'and');
                
                break;
            case 'yesterday':
                $condition['key_time']=array(array('egt', $todays-86400),array('lt',$todays-1),'and');

                break;
            case 'week':
                $condition['key_time']=array(array('egt', $todaye-604800),array('lt',TIMESTAMP),'and');
               
                break;
            case 'mouth':
                $condition['key_time']=array(array('egt', $todaye-2592000),array('lt',TIMESTAMP),'and');
            
                break;
        
            default:
               $condition['key_time']=array(array('egt', $todays),array('lt',TIMESTAMP),'and');
                
                break;
        }
        
        $condition['key_word']=$_GET['keyword'];
        $model_key=Model('key');
        $key_dtlist=$model_key->getKeyDetail($condition);
        Tpl::output('key_dtlist',$key_dtlist);
        Tpl::output('period',$period);
        Tpl::showpage('key.key_dtlist');
    }
    
}